/*
** Copyright (C) 2010 Calin Radoni
**
** This file is part of CHScanner.
**
** CHScanner is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** CHScanner is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with CHScanner. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "PacketDefinitions.h"

#define MIMIC_INC_MIN_VAL	0x0001	///< minimum allowed value for incremental types
#define MIMIC_INC_MAX_VAL	0xFFEF	///< maximum allowed value for incremental types

#define MIMIC_INC_TYPE_R	0xFFF0	///< random
#define MIMIC_INC_TYPE_RS1	0xFFF1	///< random, then incremented by 1 and shared (IPID)
#define MIMIC_INC_TYPE_R1	0xFFF2	///< random, then incremented by 1
#define MIMIC_INC_TYPE_R1S	0xFFF3	///< random, then incremented by 1 and swapped
#define MIMIC_INC_TYPE_R3S	0xFFF4	///< random, then incremented by 3 and swapped
#define MIMIC_INC_TYPE_R5	0xFFF5	///< random, then incremented by 5

enum MimicInfoIpProtocol
{
	__miipIcmp,
	__miipTcp,
	__miipUdp,
	__miipIgmp
};

class MimicInfo
{
public:
	MimicInfo(void);
	~MimicInfo(void);

	CString mimicName;				///< human-readable name
	MimicOS mimicOS;				///< mimic id

	///< IP related values
	BYTE    bTosIcmp;				///< type of service for ICMP Echo packets
	BYTE    bTosTcp;				///< type of service for TCP SYN pachets
	BYTE    bTosUdp;				///< type of service for UDP DNS pachets

	WORD    wIpIdIcmp;				///< ip id
	WORD    wIpIdTcp;				///< ip id
	WORD    wIpIdUdp;				///< ip id

	WORD    wFragOffIcmp;			///< fragment offset + fragment flags
	WORD    wFragOffTcp;			///< fragment offset + fragment flags
	WORD    wFragOffUdp;			///< fragment offset + fragment flags

	BYTE    bTTLIcmp;				///< time to live
	BYTE    bTTLTcp;				///< time to live
	BYTE    bTTLUdp;				///< time to live

	///< ICMP related valus
	WORD    wIcmpId;				///< icmp id
	WORD    wIcmpSeq;				///< icmp sequence

	///< Source port related
	WORD    srcPort;				///< in 'template' is the minimum value

	///< TCP related values
	WORD    wWindow;				///< window

	///< DNS
	WORD    wTransId;


	///< IPv6 related values
	BYTE    bTrafficClass6;		///< trafic class
	DWORD   dwFlowLabel6;		///< flow label
	BYTE    bHopLimit6_Gen;		///< hop limit - general
	BYTE    bHopLimit6_MLD;		///< hop limit - Multicast Listener Discovery
	BYTE    bHopLimit6_ND;		///< hop limit - Neighbor Discovery

	///< ICMPv6 related values
	WORD    wIcmpId6;
	WORD    wIcmpSeq6;

	///< TCPv6 related values
	WORD    wWindow6;

	///< IGMP related values
	BYTE    bMaxResponseTime;



	MimicInfo& operator = (MimicInfo&);

	void Initialize(void);

	void LoadFromPointer(MimicInfo*);

	// TODO : Ugliest piece of code, read associated comment
	///< this function SHOULD be changed
	///< Instead MimicInfoList should read the values from a file
	bool Set(MimicOS);
};
